<!--
 * @docName: authorizeTheAccount.vue
 * @Author: mwl
 * @Date: 2023/9/26
 * @LastEditors: zhongxiong
 * @LastEditTime: 11:40
-->
<template>
  <div class="content">
    <a-tabs default-active-key="1" v-model="activeKey" @change="callback">
      <a-tab-pane key="1" tab="授权公户充值">
        <authorizationEntAccount @popUpsClick='popUpsClick' :key="timer"></authorizationEntAccount>
      </a-tab-pane>
      <a-tab-pane key="2" tab="授权个人账户充值">
        <authorizationpersonalAccount @popUpsClick='popUpsClick' :key="timer"></authorizationpersonalAccount>
      </a-tab-pane>
    </a-tabs>
    <signTheContractPopups :signConfig='signConfig' @popUpsClick='popUpsClick'></signTheContractPopups>
    <howToSign :howToConfig='howToConfig' @popUpsClick='popUpsClick'></howToSign>
    <popupsPompt :popConfig='popConfig'></popupsPompt>
  </div>
</template>

<script>
import authorizationEntAccount from '@views/myAccount/modules/authorizationEntAccount';
import authorizationpersonalAccount from '@views/myAccount/modules/authorizationpersonalAccount';
import signTheContractPopups from '@views/myAccount/autModules/signTheContractPopups'
import howToSign from '@views/myAccount/autModules/howToSign'
import popupsPompt from '@views/myAccount/autModules/popupsPompt'
import { getChannelInfoLegal } from '@api/authorizationAccount'
export default {
  name: 'authorizeTheAccount',
  components:{
    authorizationEntAccount,
    authorizationpersonalAccount,
    signTheContractPopups,
    howToSign,
    popupsPompt
  },
  data(){
    return {
      dataDetails:{},
      activeKey: '1',
      timer: null,
      signConfig:{
        title:'您正在授权公户充值，请完成授权书签署',
        cloudAgreeUrl:'https://zxcloud-test.oss-cn-hangzhou.aliyuncs.com/user/contract/1693465297275_CRM.pdf',
        visible:false,
      },
      howToConfig:{
        title:'请选择您的签署方式',
        howToVisible:false,
        phone:null,
        legalCard:null
      },
      popConfig:{
        title:'授权成功',
        visible:false,
        icon:'check-circle',
        content:''
      }
    }
  },
  mounted() {
  },
  created() {

  },
  methods: {
    async callback(key) {
      //
      this.activeKey = key
      //刷新子组件
      this.timer = new Date().getTime()
    },
    popUpsClick(e){
      //签署预览弹窗
      if(e.name == 'signContract'){
          this.signConfig.visible = true;
          this.signConfig.cloudAgreeUrl = e.data.cloudAgreeUrl;
          this.howToConfig.cloudAgreeId = e.data.cloudAgreeId;
          this.howToConfig.cloudAgreeUrl = e.data.cloudAgreeUrl;
          this.dataDetails = e.data;
          //电子纸质签署弹窗
      }else if(e.name == 'howToSign'){
        if(this.$route.query.masterType == 1){
          this.getChannelLegalFun(this.dataDetails.masterId)
        }else if(this.$route.query.masterType ==2){
          let entDetailBase = JSON.parse(localStorage.getItem('entDetailBase'));

          this.howToConfig.phone = entDetailBase.legalPhone;
          this.howToConfig.legalCard = entDetailBase.cardNumber;
          console.log(123333,entDetailBase)
        }
        this.howToConfig.howToVisible = true;
      }else if(e.name == 'signedSuccess'){
        // e.type  1电子，2纸质
        if(e.type == 1){
          this.signConfig.visible = false;
          this.howToConfig.howToVisible = false;
          this.popConfig.visible = true;
        }else{
          this.signConfig.visible = false;
          this.howToConfig.howToVisible = false;
          this.popConfig.visible = true;
          this.popConfig.title = '提交成功';
          this.popConfig.content = '请耐心等待审核结果，审核通过后可通过该账号充值！'
        }

      }
    },
    //通过渠道id渠道相关详情
    getChannelLegalFun(masterId){
      getChannelInfoLegal(masterId).then((res) => {
        if(res.success){
          let data = res.result;
          if(data){
            this.howToConfig.phone = data.phone;
            this.howToConfig.legalCard = data.legalCard;
          }
        }else{
          this.$message.warning(res.message);
        }
      })
    },
  }
}
</script>

<style scoped lang="less">
.content{
  padding: 20px;
  background: #fff;

}

</style>
